package com.xuzhijie.pms.entity.vo;

import cn.hutool.core.util.StrUtil;
import com.xuzhijie.pms.entity.Pet;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
public class PetVo {
    private String id;
    private String name;
    private String  petType;
    private Integer gender;
    private String variety;
    private String color;
    private Integer isCheckIn;
    private Integer isLogOut;
    private LocalDateTime createTime;
    private String[] images;
    private String master;
        private String remark;

    public PetVo(Pet pet){
        if (pet.getType().equals(1)){
            this.petType = "狗";
        }else if (pet.getType().equals(2)){
            this.petType = "猫";
        }else if (pet.getType().equals(3)){
            this.petType = "其他";
        }
        if (pet.getImages() != null) {
            String str = pet.getImages();
            str = StrUtil.removePrefix(str, "[");
            str = StrUtil.removeSuffix(str, "]");
            // 使用逗号和空格作为分隔符拆分字符串
            List<String> split = StrUtil.split(str, ",");
            String[] strings = new String[split.size()];
            for (int i = 0; i < split.size(); i++) {
                strings[i] = split.get(i);
            }
            this.images = strings;
        }
    }

}
